using System;
using NUnit.Framework;
using dnA.Math;

namespace dnA.dnAtests.Math 
{
	[TestFixture]
	public class ComplexMath_Float_PowTest
	{
		[Test]
		public void Pow()
		{
			ComplexFloat a, b; 
			a = new ComplexFloat(1.19209289550780998537e-7f,1.19209289550780998537e-7f);
			b = new ComplexFloat(1.19209289550780998537e-7f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(9.99998047207974718744e-1f,-1.76553541154378695012e-6f), 1e-5f);
			a = new ComplexFloat(0.0f,1.19209289550780998537e-7f);
			b = new ComplexFloat(0.0f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.00000018725172576491f,1.90048076369011843105e-6f), 1e-5f);
			a = new ComplexFloat(0.0f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(0.0f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-2.56488189382693049636e-1f,-2.17823120666116144959f), 1e-5f);
			a = new ComplexFloat(0.0f,5.0e-1f);
			b = new ComplexFloat(0.0f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.06287223508090495171f,7.45007062179724087859e-1f), 1e-5f);
			a = new ComplexFloat(0.0f,-5.0e-1f);
			b = new ComplexFloat(0.0f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(3.70040633557002510874f,-3.07370876701949232239f), 1e-5f);
			a = new ComplexFloat(0.0f,2.0f);
			b = new ComplexFloat(0.0f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.24532146387429353891f,-2.27479427903521192648e1f), 1e-5f);
			a = new ComplexFloat(0.0f,-8.388608e6f);
			b = new ComplexFloat(1.19209289550780998537e-7f,0.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.00000190048219620166f,-1.87253870018168043834e-7f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,0.0f);
			b = new ComplexFloat(1.19209289550780998537e-7f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(9.9999772501398737524e-1f,-1.52596990796029252066e-6f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,1.19209289550780998537e-7f);
			b = new ComplexFloat(1.19209289550780998537e-7f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(9.99998234460792594997e-1f,1.95278892568933630108e-6f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.00000195279272155185f,-1.76554230700542567173e-6f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,1.19209289550780998537e-7f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.0000021400469319694f,1.5782887227319822572e-6f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(1.19209289550780998537e-7f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.82048207798306990457e-1f,-3.24307620835855028074f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,5.0e-1f);
			b = new ComplexFloat(1.19209289550780998537e-7f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.06287167920797422826f,7.45007298088250109031e-1f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,-5.0e-1f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.06287229912678381546f,-7.45006648647539965524e-1f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,5.0e-1f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.06287279095396722032f,7.45006826270870470906e-1f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,-5.0e-1f);
			b = new ComplexFloat(1.19209289550780998537e-7f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(3.70040633648973576176f,-3.0737099387836770671f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,1.0f);
			b = new ComplexFloat(1.19209289550780998537e-7f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.81047680751171051403f,9.00778584383872064434e-7f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,-1.0f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.81047680751171051401f,9.00778652744859086829e-7f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,1.0f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.81047795441889248392f,-9.00779004229257802805e-7f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,-1.0f);
			b = new ComplexFloat(1.19209289550780998537e-7f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.31406981499505779357e1f,-4.33317704837467381982e-6f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,2.0f);
			b = new ComplexFloat(1.19209289550780998537e-7f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.24532556821343719351f,-2.27479411632873741316e1f), 1e-5f);
			a = new ComplexFloat(1.19209289550780998537e-7f,-2.0f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.24531634737212140514f,2.27479389938842465821e1f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,2.0f);
			b = new ComplexFloat(-1.19209289550780998537e-7f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.24531735953421017366f,-2.2747944417416245858e1f), 1e-5f);
			a = new ComplexFloat(-1.19209289550780998537e-7f,-8.388608e6f);
			b = new ComplexFloat(5.0e-1f,0.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.04799999999998544808e3f,-2.04800000000001455192e3f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,0.0f);
			b = new ComplexFloat(5.0e-1f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(5.84279165479569722374e-8f,7.07106516370135390697e-1f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,1.19209289550780998537e-7f);
			b = new ComplexFloat(5.0e-1f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(7.07106781186563266789e-1f,1.42721635451415540181e-7f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(-5.0e-1f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.41421356237311419982f,5.17315171843250286477e-8f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,1.19209289550780998537e-7f);
			b = new ComplexFloat(-5.0e-1f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.85443377803337891375e-7f,-1.41421409200602374123f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(5.0e-1f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-1.15541841519997588982f,-3.19927364312925565319f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,5.0e-1f);
			b = new ComplexFloat(5.0e-1f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.0511459897104246146f,6.67813825278960257194e-1f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,-5.0e-1f);
			b = new ComplexFloat(-5.0e-1f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.7189598149893848718f,3.8333216443146435741e-1f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,5.0e-1f);
			b = new ComplexFloat(-5.0e-1f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.07140248058937952289f,-3.26040930589933104771f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,-5.0e-1f);
			b = new ComplexFloat(5.0e-1f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.09083312268613016524e-1f,-8.86262979484208589882f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,1.0f);
			b = new ComplexFloat(5.0e-1f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.89184468869136961449f,1.36850553232463909129f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,-1.0f);
			b = new ComplexFloat(-5.0e-1f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.25154230133625911883f,1.76607353802324005508f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,1.0f);
			b = new ComplexFloat(-5.0e-1f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(3.09393187799682543573f,-6.53791326174600512079f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,-1.0f);
			b = new ComplexFloat(5.0e-1f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.33516224515547153119e1f,-4.41108378192366579843e1f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,2.0f);
			b = new ComplexFloat(5.0e-1f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.44136773287116337377e1f,-1.43737200415563654774e1f), 1e-5f);
			a = new ComplexFloat(5.0e-1f,-2.0f);
			b = new ComplexFloat(-5.0e-1f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-5.06837680441339154964f,8.47393286545916475625f), 1e-5f);
			a = new ComplexFloat(-5.0e-1f,2.0f);
			b = new ComplexFloat(-5.0e-1f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-1.85757451058788304534e1f,-1.86273835390174169738e1f), 1e-5f);
			a = new ComplexFloat(1.0f,1.19209289550780998537e-7f);
			b = new ComplexFloat(1.0f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.00000000000001421085f,1.1920928955078184557e-7f), 1e-5f);
			a = new ComplexFloat(1.0f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(-1.0f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.0f,1.1920928955078184557e-7f), 1e-5f);
			a = new ComplexFloat(-1.0f,1.19209289550780998537e-7f);
			b = new ComplexFloat(-1.0f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-1.00000037450706999844f,-1.19209334195501897762e-7f), 1e-5f);
			a = new ComplexFloat(-1.0f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(1.0f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-4.81047709423856470811f,-5.73453573894732446896e-7f), 1e-5f);
			a = new ComplexFloat(1.0f,5.0e-1f);
			b = new ComplexFloat(1.0f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.2940879611878455755f,5.59164217163205818809e-1f), 1e-5f);
			a = new ComplexFloat(1.0f,-5.0e-1f);
			b = new ComplexFloat(-1.0f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(9.79027320354617600278e-1f,5.59817470921882375292e-1f), 1e-5f);
			a = new ComplexFloat(-1.0f,5.0e-1f);
			b = new ComplexFloat(-1.0f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-3.13243712712293303335f,-1.35349899429781302247f), 1e-5f);
			a = new ComplexFloat(-1.0f,-5.0e-1f);
			b = new ComplexFloat(1.0f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-1.36543645854238022036e1f,-8.85290363761184112757f), 1e-5f);
			a = new ComplexFloat(1.0f,1.0f);
			b = new ComplexFloat(1.0f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.80787929726062903957f,1.31786517290118086385f), 1e-5f);
			a = new ComplexFloat(1.0f,-1.0f);
			b = new ComplexFloat(-1.0f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(6.58932586450590431924e-1f,1.40393964863031451978f), 1e-5f);
			a = new ComplexFloat(-1.0f,1.0f);
			b = new ComplexFloat(-1.0f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-6.75361992397657144369f,-3.16978030270156142359f), 1e-5f);
			a = new ComplexFloat(-1.0f,-1.0f);
			b = new ComplexFloat(1.0f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-1.450221580753799496e1f,-1.5675771544809202808e2f), 1e-5f);
			a = new ComplexFloat(1.0f,2.0f);
			b = new ComplexFloat(1.0f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.79426068168389985952e1f,-9.85549019536299976886f), 1e-5f);
			a = new ComplexFloat(1.0f,-2.0f);
			b = new ComplexFloat(-1.0f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-3.72999124927875979445f,1.68815826725067980298f), 1e-5f);
			a = new ComplexFloat(-1.0f,2.0f);
			b = new ComplexFloat(-1.0f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-2.29273535787762074742e1f,1.25935049855290639346e1f), 1e-5f);
			a = new ComplexFloat(-2.0f,0.0f);
			b = new ComplexFloat(2.0f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(3.99999850197215368613f,3.30518208013296559626e-7f), 1e-5f);
			a = new ComplexFloat(2.0f,1.19209289550780998537e-7f);
			b = new ComplexFloat(2.0f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.00000000000003995641f,1.46318826408412115457e-7f), 1e-5f);
			a = new ComplexFloat(2.0f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(-2.0f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.49999999999995795812e-1f,5.04597181248646035514e-8f), 1e-5f);
			a = new ComplexFloat(-2.0f,1.19209289550780998537e-7f);
			b = new ComplexFloat(-2.0f,-1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.50000093626771773244e-1f,9.1449300753655074337e-9f), 1e-5f);
			a = new ComplexFloat(-2.0f,-1.19209289550780998537e-7f);
			b = new ComplexFloat(2.0f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.80978247631836073343e1f,6.53603847119075424092f), 1e-5f);
			a = new ComplexFloat(2.0f,5.0e-1f);
			b = new ComplexFloat(2.0f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(4.7643662627285056981f,6.14293657645256404233e-1f), 1e-5f);
			a = new ComplexFloat(2.0f,-5.0e-1f);
			b = new ComplexFloat(-2.0f,5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.75188217791290995924e-1f,2.00102321413576003441e-1f), 1e-5f);
			a = new ComplexFloat(-2.0f,5.0e-1f);
			b = new ComplexFloat(-2.0f,-5.0e-1f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(9.93167674872000831132e-1f,1.28054093662975414474e-1f), 1e-5f);
			a = new ComplexFloat(-2.0f,-5.0e-1f);
			b = new ComplexFloat(2.0f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.69288421203058133997e1f,7.21152386692625137958e1f), 1e-5f);
			a = new ComplexFloat(2.0f,1.0f);
			b = new ComplexFloat(2.0f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(7.88966885164614827205f,9.71958872072081690308e-1f), 1e-5f);
			a = new ComplexFloat(2.0f,-1.0f);
			b = new ComplexFloat(-2.0f,1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-5.10410704508689237391e-2f,3.13849223270419408578e-1f), 1e-5f);
			a = new ComplexFloat(-2.0f,1.0f);
			b = new ComplexFloat(-2.0f,-1.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(2.88918880975100741709f,3.5593036279880811871e-1f), 1e-5f);
			a = new ComplexFloat(-2.0f,-1.0f);
			b = new ComplexFloat(2.0f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-8.71330088091811080422e2f,6.02345829402297724033e2f), 1e-5f);
			a = new ComplexFloat(2.0f,2.0f);
			b = new ComplexFloat(2.0f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(3.36119631223856976371e1f,-1.87414050582462231776e1f), 1e-5f);
			a = new ComplexFloat(2.0f,-2.0f);
			b = new ComplexFloat(-2.0f,2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(-5.25186923787276525579e-1f,-2.9283445403509723715e-1f), 1e-5f);
			a = new ComplexFloat(-2.0f,2.0f);
			b = new ComplexFloat(-2.0f,-2.0f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.21531891781162373227e1f,-6.77639209311391411895f), 1e-5f);
			a = new ComplexFloat(-8.388608e6f,-8.388608e6f);
			b = new ComplexFloat(0.0f,1.19209289550780998537e-7f);
			TestHelper.TestRelativeError(ComplexMath.Pow(a,b), new ComplexFloat(1.00000028087842538133f,1.94179574470475151246e-6f), 1e-5f);
		}
	}
}
